package com.sg.business.commons.labelprovider.document;

import com.sg.business.model.Document;
import com.sg.business.model.User;
import com.sg.business.model.toolkit.UserToolkit;
import com.sg.widgets.commons.labelprovider.ConfiguratorColumnLabelProvider;

public class OwnerIdProvider extends ConfiguratorColumnLabelProvider {

	@Override
	public String getText(Object element) {
		if (element instanceof Document) {
			String ownerId = ((Document) element).getOwnerId();
			if (ownerId != null) {
				User owner = UserToolkit.getUserById(ownerId);
				if (owner != null) {
					return owner.getLabel();
				}
			}
		}
		return "";
	}

}
